#include "TelephoneBook.h"
#include "TelephoneInfo.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

enum choice
{
    ADD = 1,
    DELETE,
    FINDN,
    MODIFY,
    PRINT,
    FUZZY,
    BREAK
};

int main()
{
    Telebook *t = InitTelebook();
    int choice = 0;
    while (1)
    {
        system("clear");
        printf("请选择需要执行的功能1-6:\n");
        Interface(t);
        scanf("%d", &choice);
        system("clear");
        switch (choice)
        {
        case ADD:
            InsertTelebook(t);
            break;
        case DELETE:
            RemoveTelebook(t, IsEqual);
            break;
        case FINDN:
            FindByElement(t, FindEqual2);
            break;
        case MODIFY:
            ModifyByElement(t, IsEqual);
            break;
        case PRINT:
            InsertSort(t, BiggerName);
            PrintTelebook(t, PrintTelinfo);
            break;
        case FUZZY:
            FuzzyFind(t,FuzzyEqual);
            break;
        case BREAK:
            ClearTelebook(t, ClearTelinfo);
            return 0;
            break;
        default:
            printf("请输入正确的序号!\n");
            ClearTelebook(t, ClearTelinfo);
            return 0;
            // break;
        }
    }
}
